<?php

class home extends Frontend_Controller {

    public function __construct() {
        parent::__construct();
    }

    function index() {
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
        $this->frontend_data->blocks = $this->frontend_module->getBlockByType();
        $cache_html = $this->load->view('meshland/01_home', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }

    function design(){
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
		$this->frontend_data->blocks = $this->frontend_module->getBlockByType();
        $this->frontend_data->content = $this->frontend_module->getContent(1);
        $cache_html = $this->load->view('meshland/02_design', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }

	function performance(){
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
		$this->frontend_data->blocks = $this->frontend_module->getBlockByType();
        $this->frontend_data->content = $this->frontend_module->getContent(2);
        $cache_html = $this->load->view('meshland/03_performance', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }
	function product(){
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
		$this->frontend_data->blocks = $this->frontend_module->getBlockByType();
        $this->frontend_data->content = $this->frontend_module->getContent(3);
        $cache_html = $this->load->view('meshland/04_product', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }
	function gallery(){
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
        
        $cache_html = $this->load->view('meshland/05_gallery', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }
	function contact(){
        $cache_html = '';
        $this->frontend_data->sliders = $this->frontend_module->getDataSlider();
        
        $cache_html = $this->load->view('meshland/06_contact', $this->frontend_data, true);
        if ($this->enable_cache)
            $this->cache->file->save($this->cache_html_name, $cache_html, $this->cache_limit);
        echo $cache_html;
    }
    function addcontacus(){
		$R['result']=-403;
		$R['message']='Data is invalid !';
		if(isset($_SESSION["logintry"])){
			if(time()-$_SESSION["logintry"]<60*5){
				$R['result']=-1;
				$R['message']='Please waiting... 5 minute to send a next request.';
				echo json_encode($R);
				return;
			}
		}
		$Params = $this->input->get_post('Params');
		$i = $this->frontend_module->onInsertContact($Params);
		if($i===true){
			$_SESSION["logintry"] = time();
			$R['result']=1;
			$R['message']='Success !';
		}else{
			$R['result']=-901;
			$R['message']='Fail. Please try again.';
		}
		
		echo json_encode($R);
	}
        function testsendmail(){
            $this->load->library('CI_Phpmailer');
            $mail = new CI_Phpmailer();
            $mail->send_mail('ádsa','ádasd');
        }
}

?>